package btanalyzer.downloader.utils;

import java.io.File;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import btanalyzer.downloader.DownloadTask;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath*:btanalyzer/downloader/spring/appctx.xml")
public class MetadataDownloader {

	private static final String[] htmlFilePaths = {
		"../btanalyzer-db/download/20110726_1714/html",
		"../btanalyzer-db/download/20110727_2032/html",
		"../btanalyzer-db/download/20110728_0041/html",
		"../btanalyzer-db/download/20110802_1551/html",
	};

	@Test
	public void main() {
		for (String htmlDirPath : htmlFilePaths) {
			String metadataFilePath = htmlDirPath + "/../metadata/";
			new File(metadataFilePath).mkdirs();
			downloadTask.downloadMetadatas(htmlDirPath, metadataFilePath);
		}
	}
	
	@Autowired
	private DownloadTask downloadTask;
	public void setDownloadTask(DownloadTask downloadTask) {
		this.downloadTask = downloadTask;
	}
	public DownloadTask getDownloadTask() {
		return downloadTask;
	}

}
